package com.woniuxy.micromedicalserver.websocket.controller;


import com.woniuxy.micromedicalserver.bean.ResultMsg;
import com.woniuxy.micromedicalserver.bean.UserBean;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;


@RestController
@RequestMapping("/chat")
public class LoginController {

    @GetMapping(value = "/login", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResultMsg selectAll(String userName, String password, HttpServletRequest request){
            HttpSession session = request.getSession();
            UserBean userBean = new UserBean();
            userBean.setUserName(userName);
            userBean.setPassword(password);
            session.setAttribute("user", userBean.getUserName());
            //System.out.println(userBean);
            return new ResultMsg(true, userBean);
    }
}


